
import axios from "../index"
import type { UserPageVO,UserForm, ApiResponse } from "@/common/type"

export default {
    // 分页查询
    async page(page: number, pageSize: number) {
        return (await axios.get(`/admin/user/${page}?pageSize=${pageSize}`)).data as ApiResponse<UserPageVO>
    },

    // 新增
    async add(data: UserForm) {
        return (await axios.post("/admin/user", data)).data as ApiResponse<null>
    },

    // 修改
    async update(data: UserForm) {
        return (await axios.put("/admin/user", data)).data as ApiResponse<null>
    },

    // 删除
    async delete(ids: number[]) {
        const queryString = ids.map(id => `ids=${id}`).join('&');  
        return (await axios.delete(`/admin/user?${queryString}`)).data as ApiResponse<null>
    }
} 